import { configureStore, combineReducers } from "@reduxjs/toolkit";
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage"; // 默认使用 localStorage
import paramsReducer from "./modules/paramsSlice"; // 已有的模块
import TrainModelReducer from "./modules/TrainModelSlice"; // 新增模块

// 配置持久化
const persistConfig = {
  key: "root",
  storage, // 使用 localStorage 作为存储介质
};

// 合并所有 reducer
const rootReducer = combineReducers({
  params: paramsReducer, // 原有模块
  trainModel: TrainModelReducer, // 新增模块
});

const persistedReducer = persistReducer(persistConfig, rootReducer);

const store = configureStore({
  reducer: persistedReducer, // 使用持久化 reducer
});

export const persistor = persistStore(store); // 导出 persistor
export default store;
